package com.fuxian.dao.mybatisImpl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import com.fuxian.dao.UserDao;
import com.fuxian.model.User;

@Repository
public class UserDaoMybatisImpl implements UserDao {

	@Resource
	private SqlSessionTemplate sqlSessionTemplate;

	public int addUser(User user) {
	return	sqlSessionTemplate.insert("addUser", user);
	}

	public int deleteUserById(int userId) {
	return	sqlSessionTemplate.delete("deleteUserById", userId);

	}

	public int modifyUser(User user) {
	return	sqlSessionTemplate.update("modifyUser",user);

	}

	public User selectUserById(int id) {
		return sqlSessionTemplate.selectOne("selectUsersById", id);
		
	}

	public User selectUserByUserName(String userName) {
		return sqlSessionTemplate.selectOne("selectUserByUserName", userName);
	
	}

	public User selectUserByUserNamePwd(User user) {
	return sqlSessionTemplate.selectOne("selectUserByUserNamePwd", user);
	}

	public List<User> selectUsersByStatus(Map map) {
		List<User>list=sqlSessionTemplate.selectList("selectUsersByStatus", map);
		return list;
	}

	public List<User> selectUsersByUtype(Map map) {
		List<User>list=sqlSessionTemplate.selectList("selectUsersByUtype", map);
		return list;
	}

	public List<User> selectAllUsers(Map map) {
		List<User>list=sqlSessionTemplate.selectList("selectAllUsers",map);
		return list;
	}

	public int selectCount() {
		
		return sqlSessionTemplate.selectOne("selectUserCount");
	}

}
